<?php $this->headScript()->appendFile($this->js('plugins/jquery.bt.min.js'))
->appendFile($this->js('plugins/jquery.alerts.js'));
$this->headLink()->appendStylesheet($this->js('css/jquery.alerts.css'))
->appendStylesheet($this->js('css/jquery.bt.css'));
?>
<script>
$(document).ready(function(){
    $(".menu-list li").click(function(){
        $(".select-li").removeClass('select-li');
        $(this).addClass('select-li');
      });

    // 編班
    $(".create").click(function(){
        var id = $(this).attr('id').substr(3);
        $.get("<?php echo  $this->route('get-rand-run')?>",{id:id},
            function(data){
            $("#data-list").html(data);
            }
        );
     });

    // 重編
    $(".restartBtn").click(function(){
        var id = $(this).attr('id').substr(8);
        if (confirm("<?php echo $this->translate('Are you sure restart ?')?>")) {
            $.getJSON('<?php echo $this->route("reset-group-state")?>',{sn:id},function(){
            	 window.location='<?php echo  $this->route("step4")?>';
            });
        }
     });

    //結果
    $(".result").click(function(){
    	 var id = $(this).attr('id').substr(3);
    	  $.get('<?php echo  $this->route("get-result")?>',{sn:id},function(data){
    		    $("#data-list").html(data);
        });
    });

    // 班序調整
    $(".move-class").click(function(){
        var id = $(this).attr('id').substr(3);
        $.get('<?php echo  $this->route("get-class-adjustment")?>',{sn:id},function(data){
            $("#data-list").html(data);
             });
      });

    // 報表列印
    $(".print-list").click(function(){
    	   var id = $(this).attr('id').substr(3);
    	   window.location='<?php echo  $this->route("print-result")?>/sn/'+id;
     });
    //回首頁
    $("#goHomeBtn").click(function(){
        window.location='<?php echo  $this->route("index")?>';
    });
});
</script>
<style>
.listTable {background:#9ebcdd; width:75%; margin: 5px auto;}
.listTable td {padding:3px;}
.listTable th {padding:3px;font-weight: bold; text-align:center;}
.restartBtn {background:#f50}
.select-li {background:#fe0}
</style>
<form method="post" action="" name="setForm"  id="setForm">
<table class="listTable" >
<tr><th colspan=2 style="background: #fff"><?php echo  $this->translate('rand title')?>--4.進行編班作業
<input type="button" id="goHomeBtn" value="<?php echo  $this->translate('return home page')?>" />
</th></tr>
<?php if ($this->semesterList):?>
<tr><th colspan=2>點選作業項目</th></tr>
<tr style="background: #fff; "><td colspan=2 >
<div style="height: 120px; overflow: auto; padding:5px">
<ul class="menu-list">
<?php $gradeName = unserialize($this->School['length_name']);?>
<?php foreach($this->semesterList as $val):?>
<li><?php $arr = explode('-',$val['year_semester'])?>
<?php echo sprintf($this->translate('%d year %d semester %s'),$arr[0], $arr[1], $gradeName[$arr[2]])?>
<?php if ($val['is_over']  == Student_Model_StudentSemesterRandGroup::FINISHED) {$disable1='';$disable2 = "disabled='true'";}else{$disable2='';$disable1 = "disabled='true'";}?>
<input type="button"  id="s1-<?php echo $val['sn']?>" value="1.進行編班作業"  class="create"  <?php echo  $disable2?>/>
<input type="button"  id="s2-<?php echo $val['sn']?>" value="2.結果檢視"  class="result"  <?php echo  $disable1?>/>
<input type="button"  id="s3-<?php echo $val['sn']?>" value="3.班序調整"  class="move-class"  <?php echo  $disable1?> />
<input type="button"  id="s4-<?php echo $val['sn']?>" value="4.名冊列印"  class="print-list" <?php echo  $disable1?>/>
<input type="button"  id="restart-<?php echo $val['sn']?>" value="重新編班"  class="restartBtn" <?php echo  $disable1?>/>
</li>
<?php endforeach;?>
</ul>
</div>
</td></tr>
<?php endif?>
</table>

</form>
<div id="data-list">

</div>
